package com.tong.service.login;

import com.tong.RedisService;
import com.tong.dao.LoginMapper;
import com.tong.pojo.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("LoginServiceImpl")
public class LoginServiceImpl implements LoginService {

    public LoginMapper loginMapper;

    @Autowired
    private RedisService redisService;

    public void setLoginMapper(LoginMapper loginMapper) {
        this.loginMapper = loginMapper;
    }

    public Users singIn(Users users) {
        Users login = loginMapper.login(users);

        if(login == null){
            return login;
        }

        redisService.setbit("count", Long.valueOf(login.getId()),true);
        System.out.println(redisService.bitcount("count"));
        return login;
    }
}